package com.niit.dao.impl;

import java.util.List;

import com.niit.bean.Log;
import com.niit.dao.LogDao;
import com.niit.utils.DbUtil;

public class LogDaoImpl implements LogDao {

	private DbUtil util=new DbUtil();
	@Override
	public int add(Log t) { 
		String sql="insert into tb_log(tableName,operatorIP,operateType) values(?,?,?)";
		int a=util.update(sql,t.getTableName(),t.getOperatorIP(),t.getOperateType());
		return a;
	}

	@Override
	public int delete(Log t) {
		String sql="delete from tb_log where id=? ";
		int a=util.update(sql, t.getId());
		return a;
	}

	@Override
	public int update(Log t) {
		return 0;
	}

	@Override
	public List<Log> findAll(int start, int end) {
		String sql="select * from (select rownum r,tb_log.* from tb_log) a where a.r>? and a.r<=? ";
		List<Log> list=util.select(sql, Log.class, start,end);
		return list;
	}

	@Override
	public int findTotal() {
		String sql="select count(*) from tb_log";
		int count =util.selectCount(sql);
		return count;
	}

}
